home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / dec92.zip / 1012084B < prev    next >
Text File  |  1992-10-13  |  2KB  |  47 lines

  1. #include "xmath.h"
  2. #include <float.h>
  3. #define twopi 6.28318530717958647693
  4. #define twobypi .63661977236758134308
  5.  
  6. double _Sin(x, qoff)
  7. double x;
  8. unsigned int qoff;
  9. {                               /* sin(x) or cos(x) */
  10.     double g, g2;
  11.     long quad;
  12.     int big;
  13.  
  14.     if ((big = HUGE_RAD < x) || x < -HUGE_RAD) {
  15.         g = x * (1 / twopi);
  16.         x -= (big ?
  17.             (g + 1 / DBL_EPSILON) - 1 / DBL_EPSILON :
  18.             1 / DBL_EPSILON - (1 / DBL_EPSILON - g)) *
  19.             twopi;
  20.         /* Rounding mode doesn't matter */
  21.     }
  22.     g = quad = x * twobypi + (0 < x ? .5 : -.5);
  23. #if LDBL_DIG > DBL_DIG && 0
  24.         g = x - g * 1.57079632679489661923L;
  25. #else
  26.         g = (x - g * (3294198. / 2097152.)) - g *
  27.             3.139164786504813217e-7;
  28. #endif
  29.     g2 = g * g;
  30.     if ((qoff += (unsigned long) quad & 3) & 1)
  31.         g = 1 + g2 * (-.499999999999999994 + g2 *
  32.             (.041666666666666452 + g2 *
  33.                 (-.001388888888886110 + g2 *
  34.                     (.000024801587283884 + g2 *
  35.                         (-.000000275573130985 + g2 *
  36.                             (.000000002087558246 - g2 *
  37.                                 .000000000011353383))))));
  38.     else
  39.         g += g * g2 * (-.16666666666666616 + g2 *
  40.             (.00833333333332036 + g2 * (-.00019841269828653
  41.                     + g2 * (.0000027557313377252
  42.                         + g2 * (-.000000025050717097 + g2 *
  43.                             .00000000015894743)))));
  44.     return qoff & 2? -g: g;
  45. }
  46. WRAP_EOF
  47.